import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  getConnection,
  Double,
  ColumnType,
  OneToMany,
  JoinTable,
  ManyToOne,
  Unique,
  PrimaryColumn,
} from 'typeorm';
import { Exclude } from 'class-transformer';
import moment = require('moment');

@Entity()
export class Log {
  @PrimaryGeneratedColumn({
    comment: '自增ID',
  })
  id: number;

  @Column({
    nullable: false,
    comment: 'deviceId',
  })
  deviceId: number;

  @Column({
    nullable: false,
    comment: 'warn',
  })
  warn: string;

  @CreateDateColumn({
    type: 'timestamp',
    nullable: false,
    comment: '创建时间',
    update: false,
    transformer: {
      to: (value) => {
        return value;
      },
      from: (value) => {
        return moment(value).format('YYYY-MM-DD HH:mm:ss');
      },
    },
  })
  p_created_at: Date;
}
